package cn.ly.design.action.extend;

/**
 * 通用接口有不同的实现类，当发生什么情况就使用什么样策略的实现
 * 这就是策略模式
 * @author liuyu
 *
 */
public class Strategy implements IStrategy{

	@Override
	public void operate(int i) {
		if(i == 1){
			new Strategy1().operate(i);
		}else if(i == 2){
			new Strategy2().operate(i);
		}else{
			new Strategy3().operate(i);
		}
	}
	
	public static void main(String[] args) {
		IStrategy s = new Strategy();
		s.operate(1);
		s.operate(2);
		s.operate(3);
	}
	
}

interface IStrategy{
	void operate(int i);
}

class Strategy1 implements IStrategy{
	@Override
	public void operate(int i) {
		System.out.println("第[" + i + "]阶段策略：找乔国老帮忙，让吴国太给孙权施加压力");
	}
}

class Strategy2 implements IStrategy{
	@Override
	public void operate(int i) {
		System.out.println("第[" + i + "]阶段策略：赵云赤膊跪见刘备，劝说刘备大业未成");
	}
}

class Strategy3 implements IStrategy{
	@Override
	public void operate(int i) {
		System.out.println("第[" + i + "]阶段策略：孙夫人断后，挡住追兵");
	}
}


